package com.ssh;

import java.util.Arrays;

import org.junit.Test;

public class FindMinArrowShots_452 {
	public int findMinArrowShots(int[][] points) {
        Arrays.sort(points,(a,b) -> (a[0]-b[0]));
        int sum = 1,p = points[0][1];
        for (int i = 1; i < points.length; i++) {
        	if (points[i][0] < p) {
        		continue;
        	}
        	p = points[i][1];
        	sum++;
        }
        return sum;
    }
	
	@Test
	public void test () {
		int[][] c = new int[][]{{3,9},{7,12},{3,8},{6,8},{9,10},{2,9},{0,9},{3,9},{0,6},{2,8}};
		 Arrays.sort(c,(a,b) -> (b[1]-a[1]));
		for (int i = 0; i < c.length; i++) {
			System.out.println(c[i][0]+"------"+c[i][1]);
		}
	}
}
